package com.dingding.baseservice.push.order.publishorder;

import com.dingding.bean.databean.request.ReqPublishAboutCar;
import com.dingding.bean.databean.response.DataResponse;
import com.dingding.common.core.config.SystemCode;
import com.dingding.service.BaseService;

public abstract class AbstractPublishOrderHandler extends BaseService {

	protected AbstractPublishOrderHandler abstractPublishOrderHandler;

	/**
	 * 
	 * @Title: publishOrderExcute 
	 * @Description: TODO(这里用一句话描述这个方法的作用) 
	 * @param publishAboutCar客户端请求封装bean
	 * @param dataResponse 服务端响应封装bean
	 * @since 1.8.0
	 * @author CHEHAUNBO
	 * 
	 */
	public abstract void publishOrderExcute(ReqPublishAboutCar publishAboutCar, DataResponse dataResponse);

	public AbstractPublishOrderHandler getAbstractPublishOrderHandler() {

		return abstractPublishOrderHandler;

	}

	public void setAbstractPublishOrderHandler(AbstractPublishOrderHandler abstractPublishOrderHandler) {
		this.abstractPublishOrderHandler = abstractPublishOrderHandler;
	}

	/**
	 * 设置响应状态
	 */
	@Override
	public void setStatus(DataResponse dataResponse, int status) {

		String message = null;
		switch (status) {
		case SystemCode.SUCCESS:
			message = SystemCode.SUCCESS_MESSAGE;
			break;
		case SystemCode.ERROR:
			message = SystemCode.ERROR_MESSAGE;
			break;
		case SystemCode.USER_INFO_NOT_EXIST_ERROR: // 用户信息不存在
			message = SystemCode.USER_INFO_NOT_EXIST_MESSAGE;
			break;
		case SystemCode.CANCEL_ORDER_TOO_MUCH: // 取消次数超过三次
			message = SystemCode.CANCEL_ORDER_MUCH_MESSAGE;
			break;
		case SystemCode.PUBLISH_ORDER_TOO_MUCH: // 接单次数超过三次
			message = SystemCode.PUBLISH_ORDER_TOO_MUCH_MESSAGE;
			break;
		case SystemCode.DATA_NULL_ERROR: // 请求数据为空
			message = SystemCode.DATA_NULL_MESSAGE;
			break;
		case SystemCode.ORDER_NOT_EXIST_ERROR: // 订单不存在
			message = SystemCode.ORDER_NOT_EXIST_MESSAGE;
			break;
		case SystemCode.USER_GRAB_ORDER_ERROR: // 订单已被抢
			message = SystemCode.USER_GRAB_ORDER_MESSAGE;
			break;
		case SystemCode.SET_OUT_TIME_ERROR: // 发单时间有误
			message = SystemCode.SET_OUT_TIME_MESSAGE;
			break;
		case SystemCode.USER_PLACE_ORDER_ERROR: // 您尚有未完成订单
			message = SystemCode.USER_PLACE_ORDER_MESSAGE;
			break;
		default:
			break;
		}
		dataResponse.setResponseCode(status);
		dataResponse.setResponseMessage(message);
	}
}
